<!--
 * @Author: houmin 745762351@qq.com
 * @Date: 2023-11-29 15:43:54
 * @LastEditors: houmin 745762351@qq.com
 * @LastEditTime: 2023-12-03 20:20:29
 * @FilePath: \tch-h5\src\views\home\components\GoldPandaCard.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup>
import { useRouter } from "vue-router";
import { defineProps, ref, watch } from "vue";
// import panda from "@/assets/images/oneCard/panda.png";
// import qr from "@/assets/images/oneCard/qr.png";

const props = defineProps({
  data: Object,
});

const router = useRouter();

const userInfo = ref([]);

watch(
  () => props.data,
  (newValue, oldVal) => {
    userInfo.value = newValue;
  },
  { deep: true }
);
</script>

<template>
  <div class="card">
    <div class="name">嗨耍卡</div>
    <div class="content">
      <div class="avatar">
        <van-image
          width="110"
          height="100%"
          :src="userInfo?.value?.[0]?.coverImage"
        />
      </div>
      <div
        class="details"
        @click="
          () =>
            router.push({
              path: 'haishua-details',
              query: { cardId: userInfo?.value?.[0]?.cardId },
            })
        "
      >
        <p class="title">{{ userInfo?.value?.[0].cardName }}</p>
        <!-- <p class="desc">
          {{ userInfo?.value?.[0].cardDesc }}
        </p> -->
        <div class="desc" v-html="userInfo?.value?.[0].cardDesc "></div>
        <div class="footer">
          <span class="num">¥{{ userInfo?.value?.[0].nowPrice }}</span>
          <span class="txt-del">¥{{ userInfo?.value?.[0].originalPrice }}</span>
          <van-button round class="btn" v-if="userInfo?.value?.[0]?.openStatus==0">立即开通</van-button>
          <p v-else>
              <span class="text-orange">有效日期至：{{userInfo?.value?.[0]?.expireTime}}</span>
              <span class="fr text-blue">已开通</span>
            </p>
        </div>
      </div>
    </div>
    <div class="list">
      <div class="item">
        <div class="avatar">
          <van-image
            width="80"
            height="100%"
            :src="userInfo?.value?.[1].coverImage"
          />
        </div>
        <div
          class="details"
          @click="
            () =>
              router.push({
                path: 'haishua-details',
                query: { cardId: userInfo?.value?.[1]?.cardId },
              })
          "
        >
          <p class="title">{{ userInfo?.value?.[1].cardName }}</p>
          <div class="footer">
            <span class="num">¥{{ userInfo?.value?.[1].nowPrice }}</span>
            <van-button round class="btn">{{userInfo?.value?.[1]?.openStatus==0?'开通':'已开通'}}</van-button>
            <van-icon name="arrow" size="1rem" />
          </div>
        </div>
      </div>
      <div class="item">
        <div class="avatar">
          <van-image
            width="80"
            height="100%"
            :src="userInfo?.value?.[2].coverImage"
          />
        </div>
        <div
          class="details"
          @click="
            () =>
              router.push({
                path: 'haishua-details',
                query: { cardId: userInfo?.value?.[2]?.cardId },
              })
          "
        >
          <p class="title">{{ userInfo?.value?.[2].cardName }}</p>
          <p class="footer">
            <span class="num">¥{{ userInfo?.value?.[2].nowPrice }}</span>
            <van-button round class="btn">{{userInfo?.value?.[2]?.openStatus==0?'开通':'已开通'}}</van-button>
            <van-icon name="arrow" size="1rem" />
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.card {
  overflow: hidden;
  background-color: #ffffff;
  border-radius: 1rem;
  padding: 0.5rem;
  margin: 1.5rem;
  // box-shadow: 0 0.7rem 1.5rem 0 rgba(54, 141, 88, 0.05);
  box-shadow: 2px 2px 6px rgba(189, 189, 189, 0.7);
  .name {
    margin: 1rem 0 1rem 1rem;
    font-weight: bold;
    font-size: 1.6rem;
  }
  .content {
    display: flex;
  }
  .avatar {
    margin-right: 1rem;
  }
  .title {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 1rem;
  }
  .details {
    position: relative;
    font-size: 1.4rem;
    line-height: 1.5;
    flex: 1;
    .qr {
      position: absolute;
      right: 4rem;
      top: -1rem;
      font-size: 1.2rem;
    }
  }
  .num {
    font-size: 1.8rem;
    font-weight: bold;
    color: rgba(239, 119, 35, 1);
  }
  .desc {
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    // color: #ffffff;
  }
  .txt-del {
    margin-left: 1rem;
    text-decoration: line-through;
    color: rgba(139, 139, 139, 1);
  }
  .btn {
    height: 2.4rem;
    margin-right: 1rem;
    float: right;
    border: none;
    font-weight: bold;
    background: linear-gradient(
      180deg,
      rgba(228, 232, 178, 1) 0%,
      rgba(166, 225, 193, 1) 100%
    );
  }
  .list {
    display: flex;
    margin-top: 2rem;
    justify-content: space-between;
    .details {
      margin-top: 2rem;
    }
    .title {
      margin-bottom: 2.5rem;
    }
  }
  .item {
    display: flex;
    .num {
      font-size: 1.6rem;
    }
    .btn {
      padding: 0 5px;
      font-size: 1.2rem;
      margin-left: 4px;
      margin-right: 0;
      float: none;
      vertical-align: middle;
    }
    .footer {
      margin-top: 1rem;
    }
    .avatar {
      margin-right: 0;
    }
  }
}
</style>
